package cn.e4j.modular.api.controller;

import cn.e4j.core.dto.impl.Dto;
import cn.e4j.core.dto.requestDtoResolver.DtoParam;
import cn.e4j.core.dto.requestDtoResolver.DtoWapper;
import cn.e4j.core.reqres.response.ResponseData;
import cn.e4j.core.util.LangUtils;
import cn.e4j.modular.api.service.ZskService;
import cn.e4j.modular.api.util.ControllerSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("api/wx/zsk")
@RestController
public class ZskController extends ControllerSupport {

    @Autowired
    ZskService zskService;

    @RequestMapping("getListData")
    public ResponseData getList(@DtoParam DtoWapper wapper){
        List<Dto> dtoList = new ArrayList<>();
        Dto inDto = wapper.getDto();
        try {
            inDto.put("LANG", LangUtils.getLang(inDto.getString("LANG")));
            dtoList = zskService.getListData(wapper.getPage(),inDto);
        }catch (Exception e){
            e.printStackTrace();
            return ERROR;
        }
        return SUCCESS(dtoList);
    }

}
